<?php 
ob_start();
session_start();
require('../gest_login.php');
require('../languages/it.php');
require('../structure.php');
reserved_page();
admin_page();
include("../database.php"); 	
mysql_select_db($database_database, $database);
$query = "SELECT name, surname, user, mail, admin, verificated, place, id_fb, id FROM users ORDER BY surname";
$result = mysql_query($query, $database) or die(mysql_error());
$result_rows = mysql_num_rows($result);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script type="text/javascript">
	var page = "admin";
</script>
<?php
get_header();
get_css();
get_js();
?>
</head>
<body class="grunge">
<div id="wrapper">
	<div id="header_container">
		<div id="header">
			<h1 id="logo"> <a href="index.html">Xero HTML &amp; CSS Template</a> </h1>
			<!-- end logo -->
			
			<?php get_nav(); ?>
			
			<div class="clear"></div>
			<!-- clears floted logo & nav -->
			
			<div id="page_title">
				<ul class="breadcrumb_nav">
					<li><a href="../">Home</a></li>
					<li><a href="#">Registrati</a></li>
				</ul>
				<h1>Amministrazione</h1>
			</div>
			<!-- end page title -->
			
		</div>
		<!-- end header (940px width) --> 
	</div>
	<!-- end header container (100% width) -->
	<div id="body_content">
		<div id="content" class="">
			<div class="full">
				<h2>Utenti<em class="heading_description"></em></h2>
				<? echo get_admin_users_action($_GET['action'], $_GET['id']);?>
				<table> 
				<tbody> 
					<tr> 
						<th></th>
						<th>Nome</th> 
						<th>Cognome</th> 
						<th>User</th> 
						<th>Mail</th>
						<th>Admin</th>
						<th>Ver</th>
						<th>Luogo</th>
						<th>ID Facebook</th>
						<th>ID</th>
					</tr> 
					<? while($row=mysql_fetch_array($result)){ ?>
					<tr> 
						<td rowspan="2"><? if ($row['id_fb']) { ?><img src="http://graph.facebook.com/<? echo $row['id_fb']; ?>/picture"/><? } ?></td>
						<td rowspan="2"><? echo $row['name']; ?></td> 
						<td rowspan="2"><? echo $row['surname']; ?></td> 
						<td rowspan="2"><? echo $row['user']; ?></td>
						<td><? echo $row['mail']; ?></td>
						<td><? if($row['admin']) echo 'Si'; else echo 'No'; ?></td>
						<td><? if($row['verificated']) echo 'Si'; else echo 'No'; ?></td>
						<td><? echo $row['place']; ?></td> 
						<td><? if($row['id_fb'] == 0) echo '-'; else {?><a href="<? echo get_fb_link($row['id_fb']); ?>" target="_blank"><? echo $row['id_fb']; }?></a></td>
						<td><? echo $row['id']; ?></td>
						<tr>
							<td colspan="6">
								<ul class="button_array"> 
									<li><a href="../delete.php?id=<? echo $row['id']; ?>&by_admin=1" class="small_button">Elimina Utente</a></li> 
									<li><? if ($row['admin']) { ?><a href="users.php?action=no_admin&id=<? echo $row['id']; ?>" class="small_button">Nega Amministrazione</a><? } else { ?><a href="users.php?action=yes_admin&id=<? echo $row['id']; ?>" class="small_button">Rendi Amministratore</a><? } ?></li> 
									<li><a href="#" class="small_button">Invia Mail</a></li>
									<li><a href="#" class="small_button">Vedi Foto</a></li>
								</ul>
							</td>
						</tr>
					</tr> 
					<? } ?>
				</tbody> 
			</table> 
			</div>
		</div>
	</div>
	<!-- end body content -->
	
	<?php get_footer(); ?>
	
</div>
<!-- end wrapper -->
</body>
</html>